export const pageJumpMixin = {


  onShow() {
    this.showApplyModal = false;
  },

  methods: {
    pageJump(item) {
      this.showDesignApplyTypeRadio = false;
      this.designApplyType = 1;

      // 渠道信息调整
      if (item.CustomNo == 8 || item.CustomNo == 7) {
        this.$u.route({
          url: '/pages/home/dealer/index'
        });
        return false;
      }

      // 渠道信息维护
      if (item.CustomNo == 9) {
        this.apply('information', item);
        return false;
      }

      // 模板样机申请
      if (item.CustomNo == 10) {
        this.apply('module', item);
        return false;
      }

      // 户外套装申请
      if (item.CustomNo == 11) {
        this.apply('outdoor', item);
        return false;
      }

      // 门店奖牌申请
      if (item.CustomNo == 12) {
        this.apply('medals', item);
        return false;
      }

      // 渠道设计申请
      if (item.CustomNo == 13) {
        this.apply('doorDesign', item);
        return false;

      }

      // 门店动力金申请 //渠道补贴申请
      if (item.CustomNo == 14 || item.CustomNo == 15) {
        this.apply('storeCosts', item);
        return false;
      }


      // 渠道调整审批 
      //  0: {Key: "1", Value: "信息调整"}
      if (item.CustomNo == 16) {
        this.$u.vuex('vuex_temId', 1)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 渠道信息审批
      // 1: {Key: "2", Value: "信息维护"}
      if (item.CustomNo == 17) {
        this.$u.vuex('vuex_temId', 2)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 模板样机审批
      // 2: {Key: "4", Value: "模块样机"}
      if (item.CustomNo == 19) {
        this.$u.vuex('vuex_temId', 4)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 户外套装审批
      // 3: {Key: "5", Value: "户外套装"}
      if (item.CustomNo == 20) {
        this.$u.vuex('vuex_temId', 5)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 门店奖牌审批
      // 4: {Key: "6", Value: "门店奖牌"}
      if (item.CustomNo == 21) {
        this.$u.vuex('vuex_temId', 6)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 渠道设计审核
      // 5: {Key: "7", Value: "门店设计"}
      if (item.CustomNo == 22) {
        this.$u.vuex('vuex_temId', 7)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 动力金审批
      // 6: {Key: "8", Value: "动力金审批"}
      if (item.CustomNo == 23) {
        this.$u.vuex('vuex_temId', 8)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 渠道补贴审批
      // 7: {Key: "9", Value: "渠道补贴审批"}
      if (item.CustomNo == 24) {
        this.$u.vuex('vuex_temId', 9)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 积分物料审批
      // 8: {Key: "16", Value: "物料申请"}
      if (item.CustomNo == 25) {
        this.$u.vuex('vuex_temId', 16)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 模板样机验收
      // 10: {Key: "10", Value: "模块样机验收"}
      if (item.CustomNo == 26) {
        // this.$u.vuex('vuex_temId', 10)
        this.$u.route({
          url: '/pages/apply/store/flagshipStore'
        });
        return false;
      }

      // 门店奖牌验收
      // 11: {Key: "12", Value: "奖牌验收"}
      if (item.CustomNo == 28) {
        this.$u.vuex('vuex_temId', 12)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 活动设计验收
      // 12: {Key: "13", Value: "活动设计验收"}
      if (item.CustomNo == 29) {
        this.$u.vuex('vuex_temId', 13)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 动力金协议
      // 13: {Key: "14", Value: "动力金协议验收"}
      if (item.CustomNo == 30) {
        this.$u.vuex('vuex_temId', 14)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      // 门店协议
      // 14: {Key: "15", Value: "门头协议验收"}
      if (item.CustomNo == 31) {
        this.$u.vuex('vuex_temId', 15)
        uni.switchTab({
          url: '/pages/review/index',
        })
        return false;
      }

      if (item.CustomNo == 34) {
        this.$u.route('/pages/marketCosts/market/index');
        return false;
      }

      if (item.CustomNo == 35) {
        this.$u.route('/pages/marketCosts/bu/index');
        return false;
      }

      if (item.CustomNo == 36) {
        this.$u.route('/pages/marketCosts/sales/predictionList');
        return false;
      }

    },

    toList(type) {
      let url, params;

      if (type == 'module') {
        url = '/pages/review/module/index';
      }

      if (type == 'moduleAcceptance') {
        url = '/pages/review/module/acceptance';
      }

      if (type == 'information') {
        url = '/pages/review/information/index';
        params = {
          SelectType: 1
        };
      }

      if (type == 'storePhotoReview') {
        url = '/pages/review/information/index';
        params = {
          SelectType: 2
        };
      }

      if (type == 'change') {
        url = '/pages/review/change/index';
      }

      if (type == 'outdoor') {
        url = '/pages/review/outdoor/index';
      }

      if (type == 'outdoorAcceptance') {
        url = '/pages/review/outdoor/acceptance';
      }

      if (type == 'medals') {
        url = '/pages/review/medals/index';
      }

      if (type == 'medalsAcceptance') {
        url = '/pages/review/medals/acceptance';
      }

      if (type == 'doorCosts') {
        url = '/pages/review/doorCosts/index';
      }

      if (type == 'storeCosts') {
        url = '/pages/review/storeCosts/index';
      }

      if (type == 'design') {
        url = '/pages/review/design/index';
      }

      if (type == 'otherDesignAcceptance') {
        url = '/pages/review/agreement/index';
        params = {
          SelectType: 3
        };
      }

      if (type == 'doorAgreement') {
        (url = '/pages/review/agreement/index'),
        (params = {
          SelectType: 1
        });
      }

      if (type == 'storeAgreement') {
        url = '/pages/review/agreement/index';
        params = {
          SelectType: 2
        };
      }

      this.$u.route({
        url,
        params
      });
    },

    apply(type, item) {
      if (item) {
        this.modalTitle = item.Name
      }

      this.applyType = type;
      this.showApplyModal = true;

      if (type == 'module') {
        this.showApplyDouble = true;
        this.showApplyStore = true;
        this.storeRequired = true;
      }

      if (type == 'outdoor') {
        this.showApplyDouble = true;
        this.showApplyStore = false;
      }

      if (type == 'medals') {
        this.showApplyDouble = true;
        this.showApplyStore = true;
        this.storeRequired = true;
      }

      if (type == 'otherDesign') {
        this.showApplyDouble = true;
        this.showApplyStore = true;
        this.storeRequired = false;
      }

      if (type == 'doorDesign' || type == 'storeDesign' || type == 'doorCosts' || type == 'storeCosts') {
        this.showApplyDouble = true;
        this.showApplyStore = true;
        this.storeRequired = true;

        if (type != 'storeCosts') {
          this.showDesignApplyTypeRadio = true
        }


        if (item.CustomNo == 14) {
          this.params.ApplyForType = 1
        }
        if (item.CustomNo == 15) {
          this.params.ApplyForType = 2
        }
      }

      if (type == 'information') {
        this.showApplyDouble = true;
        this.showApplyStore = true;
        this.storeRequired = false;
      }

      if (type == 'storePhoto') {
        this.showApplyDouble = true;
        this.showApplyStore = true;
        this.storeRequired = true;
      }
    },

    toApplyPage() {
      if (this.designApplyType == 4) {
        this.$u.route({
          url: '/pages/apply/design/index',
          params: {
            SelectType: 4
          }
        });
        return false;
      }


      let dealerId = this.params.FirstDealerId;

      if (!dealerId) {
        this.$u.toast('请选择一级经销商');
        return false;
      }

      if (this.showApplyDouble) {
        if (this.params.DoubleDealerId) {
          dealerId = this.params.DoubleDealerId;
        }
      }

      if (this.showApplyStore) {
        if (this.storeRequired) {
          if (!this.params.DoubleDealerId) {
            this.$u.toast('请选择二级经销商');
            return false;
          }

          if (!this.params.StoreDealerId) {
            this.$u.toast('请选择门店');
            return false;
          }
        }

        if (this.params.StoreDealerId) {
          dealerId = this.params.StoreDealerId;
        }
      }


      if (this.designApplyType == 6 || this.designApplyType == 7) {

        this.$u.route({
          url: '/pages/apply/design/flagshipStore',
          params: {
            ObjectType: this.designApplyType,
            DealerId: dealerId,
          }
        });
        return false;
      }

      let url;

      let params = {
        DealerId: dealerId,
        ApplyForType: this.params.ApplyForType
      };

      if (this.applyType == 'module') {
        this.checkModuleApplyIsOk(dealerId, 1).then(res => {
          if (res) {
            url = '/pages/apply/module/index';
            this.$u.route({
              url: url,
              params: params
            });
          }
        });
        return false;
      }

      if (this.applyType == 'outdoor') {
        this.checkModuleApplyIsOk(dealerId, 4).then(res => {
          if (res) {
            url = '/pages/apply/outdoor/index';
            this.$u.route({
              url: url,
              params: params
            });
          }
        });
        return false;
      }

      if (this.applyType == 'medals') {
        this.checkModuleApplyIsOk(dealerId, 5).then(res => {
          if (res) {
            url = '/pages/apply/medals/index';
            this.$u.route({
              url: url,
              params: params
            });
          }
        });
        return false;
      }

      if (this.applyType == 'otherDesign') {
        url = '/pages/apply/design/index';
        params.SelectType = 3;
        this.$u.route({
          url: url,
          params: params
        });
        return false;
      }

      if (this.applyType == 'doorDesign') {
        url = '/pages/apply/design/index';
        params.SelectType = this.designApplyType;
        this.$u.route({
          url: url,
          params: params
        });
        return false;
      }

      if (this.applyType == 'storeDesign') {
        url = '/pages/apply/design/index';
        params.SelectType = this.designApplyType;
        this.$u.route({
          url: url,
          params: params
        });
        return false;
      }

      if (this.applyType == 'doorCosts') {
        url = '/pages/apply/doorCosts/index';
        this.$u.route({
          url,
          params
        });
        return false;
      }

      if (this.applyType == 'storeCosts') {

        url = '/pages/apply/storeCosts/index';
        this.$u.route({
          url,
          params
        });
        return false;
      }

      if (this.applyType == 'information') {
        url = '/pages/apply/information/index';
        this.$u.route({
          url,
          params
        });
        return false;
      }

      if (this.applyType == 'storePhoto') {
        url = '/pages/apply/information/storePhoto';
        this.$u.route({
          url,
          params
        });
        return false;
      }

      this.showApplyModal = false;
      this.resetSearch();
    },

  }
}